//
//  PerCell.m
//  operativeSide-2.0
//
//  Created by 马腾飞 on 16/12/19.
//  Copyright © 2016年 王春程. All rights reserved.
//

#import "PerCell.h"
#import <Masonry/Masonry.h>

@interface PerCell()

@property (nonatomic, strong) UIView *topLineView;
@property (nonatomic, strong) UIView *bottomLineView;

@property (nonatomic, strong) UIView *grayView;
@property (nonatomic, strong) UIImageView *arrowView;


@end

@implementation PerCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.selectionStyle = UITableViewCellSelectionStyleNone;
        self.backgroundColor = [UIColor whiteColor];
        [self createUI];
    }
    return self;
}

- (void)createUI {
    
    self.grayView = [[UIView alloc] init];
    self.grayView.backgroundColor = RGB(238, 238, 238);
    [self.contentView addSubview:self.grayView];
    
    self.topLineView = [[UIView alloc] init];
    self.topLineView.backgroundColor = RGB(219, 219, 219);
    [self.contentView addSubview:self.topLineView];

    
    self.iconView = [[UIImageView alloc] init];
    self.iconView.contentMode = UIViewContentModeScaleAspectFit;
    [self.contentView addSubview:self.iconView];
    
    self.optionLabel = [[UILabel alloc] init];
    self.optionLabel.textColor = RGB(0, 0, 0);
    self.optionLabel.textAlignment = NSTextAlignmentLeft;
    self.optionLabel.font = [UIFont systemFontOfSize:14];
    [self.contentView addSubview:self.optionLabel];
    
    self.arrowView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"per_arrow"]];
    [self.contentView addSubview:self.arrowView];
    
    self.bottomLineView = [[UIView alloc] init];
    self.bottomLineView.backgroundColor = RGB(219, 219, 219);
    [self.contentView addSubview:self.bottomLineView];
    
}

- (void)layoutSubviews {
    WS(ws);
    
    [self.topLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(ws.contentView.mas_left);
        make.right.equalTo(ws.contentView.mas_right);
        make.top.equalTo(ws.contentView.mas_top).offset(10.1);
        make.height.equalTo(0.5);
    }];
    
    [self.grayView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(ws.contentView.mas_left);
        make.top.equalTo(ws.contentView.mas_top);
        make.right.equalTo(ws.contentView.mas_right);
        make.height.equalTo(10);
    }];
    
    [self.iconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(ws.contentView.mas_left).offset(17);
        make.centerY.equalTo(ws.contentView.mas_centerY).offset(5);
        make.size.equalTo(CGSizeMake(16, 16));
    }];
    
    [self.optionLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(ws.contentView.mas_left).offset(48);
        make.centerY.equalTo(ws.contentView.mas_centerY).offset(5);
        make.height.equalTo(14);
    }];
    
    [self.arrowView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.equalTo(ws.contentView.mas_right).offset(-14);
        make.centerY.equalTo(ws.contentView.mas_centerY).offset(5);
        make.size.equalTo(CGSizeMake(7, 12));
    }];
    
    [self.bottomLineView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(ws.contentView.mas_left);
        make.right.equalTo(ws.contentView.mas_right);
        make.bottom.equalTo(ws.contentView.mas_bottom);
        make.height.equalTo(0.5);
    }];
}

@end
